<?php
#基础函数
include_once('_path.php');
include_once("../includes/init.php");

####变量
$uid = intval($_GET['uid']);

#翻页
$page = trim($_GET['page']) + 0; if ($page == "") { $page = $_COOKIE['mmpage']; }
$pagesize = 20;

#!!翻页
if ($page < 1) $page = 1;

#总共数量
$rs_count = $database->queryArray("SELECT count(*) total FROM members_message WHERE uid=".$uid." AND rid=0");
$total_page = ceil($rs_count[0]["total"] / $pagesize);
if ($total_page < 1) $total_page = 1;
if ($page > $total_page) $page = $total_page;

set_cookie('mmpage', $page, time() + 604800);

#正式查询
$rsc = $database->queryArray("SELECT m.*,mu.name FROM members_message m LEFT JOIN members_info mu ON mu.id = m.uid  WHERE m.uid=".$uid." AND m.rid=0  ORDER BY dateline DESC LIMIT ".(($page - 1) * $pagesize).", $pagesize");
#样式
$css = array();
$js = array("custom");
include_once("../layout/_header.php");
?>
<div class="main">
        <div class="traininc-nav-list">
            		<ul>
                                <li><a href="<?= _CONST_BACKEND_URL ?>/members/edit.php?action=view.form&id=<?=$uid ?>">基本信息</a></li>
                                <li><a href="<?= _CONST_BACKEND_URL ?>/files/index.php?uid=<?=$uid?>">文件上传</a></li>
                                <li class="selected"><a href="javascript:">留言管理</a></li>
                                <li><a href="<?= _CONST_BACKEND_URL ?>/cardbind/index.php?uid=<?=$uid?>">绑定会员卡</a></li>
				</ul>
                </div>
                <div class="box-con">
                    <form name="edit" action="update.php?uid="<?=$uid?> method="post">
                <table id="table1" class="table-blue">
                        <thead>
                                <tr>
                                        <th><input name="aa" class="checkall" type="checkbox"></th>
                                        <th>编号</th>
                                        <th>姓名</th>
                                        <th>留言</th>
                                        <th>管理员回复</th>
                                        <th>操作</th>
                                </tr>
                        </thead>
                        <tbody>
                                <?
                                for($i=0;$i<sizeof($rsc);$i++){
                                $r = $rsc[$i];
                                $j = 1;
                                ?>
                                <tr <?=iif($j%2==0, 'class="odd"')?>>
                                        <td><input type="checkbox" name="ids[]" value="<?=$r['id']?>"></td>
                                        <td><?=$r['id']?></td>
                                        <td><?=$r['name']?></td>
                                        <td><?=$r['content']?><br />
                                            <?=date(_CONST_DATE_FORMAT.' '._CONST_TIME_FORMAT,$r['dateline'])?>
                                        </td>
                                        <td>
                                        <?php
                                        $pr = array();
                                        $pr = $database->queryFirst("SELECT content,dateline FROM members_message WHERE rid=".$r['id']);
                                        if($pr['content']){
                                        ?>
                                        <?=$pr['content']?><br />
                                        <?=date(_CONST_DATE_FORMAT.' '._CONST_TIME_FORMAT,$pr['dateline'])?>
                                        <?php
                                        }
                                        ?>
                                        </td>
                                        <td><?=iif(empty($pr['content']), "<a href=\"edit.php?action=add.form&id=".$r[id]."&uid=".$uid."\">回复</a> | ")?><a href="edit.php?action=delete.do&id=<?= $r['id'] ?>&uid=<?=$uid?>">删除</a></td>
                                </tr>
                                <?
                                $j++;
                                }
                                ?>
                        </tbody>
                </table>
                    <div class="batch-admin"><input class="checkall" type="checkbox"> 全选/反选  <input type="submit" name="" value="删除" class="btnA" /><input type="hidden" name="type" value="delete" /></div>
                </form>
                <div class="digg">
                <? pagination($page, $pagesize, $rs_count[0]["total"], "index.php&page=%s%") ?>
                </div>
                </div>
</div>
<?
include_once("../layout/_footer.php");
?>